﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace MyHealthByDesignWebsite.Models
{
    public class HealthProfileRepository
    {
        //Description:  Repository for health profile
        //Created:  Nov 2011
        //Programmer:  Bob Whiteis

        private FullDataSetDataContext db = new FullDataSetDataContext();
        //
       //pre-condition:  helath profile id had been supplied
        //post-condition: health profile has been returned
        public HealthProfile GetHealthProfile(int id)
        {
            return db.HealthProfiles.SingleOrDefault(hp => hp.HP_healthProfileID == id);
        }
        //
        // Insert/Delete Methods
        //pre-condition:  helath profile had been supplied
        //post-condition: health profile data has been saved to database
        public void Add(HealthProfile healthProfile)
        {
            db.HealthProfiles.InsertOnSubmit(healthProfile);
        }

        //pre-condition:  helath profile had been supplied
        //post-condition: health profile data has been deleted
        public void Delete(HealthProfile healthProfile)
        {

            db.HealthProfiles.DeleteOnSubmit(healthProfile);
        }
        //
        // Persistence
        public void Save()
        {
            db.SubmitChanges();
        }
    }
}